package com.my.bean;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @Description TODO
 * @Author marshal
 * @Date 11/12/19 8:38 AM
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("t_user")
public class MpUser extends Model<MpUser> {

    private Long id;
    private String name;
    // 设置这个注解以后，保存的时候age字段，传参失败；查询的时候，也不会返回这个字段
    @JsonIgnore
    private Integer age;

    /**
     *
     * <a href="https://baomidou.com/pages/fd41d8/">JSON数据处理<a/>
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<String> hobbies;

    /**
     * json 格式数据
     */
        @TableField(typeHandler = JacksonTypeHandler.class)
    private Info info;


    /**
     * 逻辑删除【0：未删除，1：删除】，加入逻辑删除字段以后，查询SQL会自动拼接上一个条件 WHERE deleted=0
     */
    @TableLogic
    private Integer deleted;

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public final static class Info {
        private String country;
        private String language;
    }
}
